package cn.edu.neusoft.wuguangsheng.flowerimpression.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;

import java.util.List;

import cn.edu.neusoft.wuguangsheng.flowerimpression.R;
import cn.edu.neusoft.wuguangsheng.flowerimpression.adapter.EmptyRecyclerView;
import cn.edu.neusoft.wuguangsheng.flowerimpression.adapter.UserFKnowAllCommentAdapter;
import cn.edu.neusoft.wuguangsheng.flowerimpression.bean.AllCommentKnowBean;
import cn.edu.neusoft.wuguangsheng.flowerimpression.listener.ListListener;
import cn.edu.neusoft.wuguangsheng.flowerimpression.model.GetAllCommentListModel;

public class AllKnowCommentActivity extends BaseActivity {
    private List<AllCommentKnowBean> items;
    EmptyRecyclerView all_know_comment_rv;
    private boolean up = false;
    View all_know_comment_emptyview;
    ImageView all_know_comment_fh;

    @Override
    void initView() {
        setLayout_file(R.layout.activity_all_know_comment);
        all_know_comment_rv = (EmptyRecyclerView)findViewById(R.id.all_know_comment_rv);
        all_know_comment_emptyview = (View)findViewById(R.id.all_know_comment_emptyview);
        all_know_comment_fh = (ImageView)findViewById(R.id.all_know_comment_fh);

        GetAllCommentListModel getAllCommentListModel = new GetAllCommentListModel();
        getAllCommentListModel.getAllCommentList(getid(),allCommentKnowBeanListListener);
    }
    @Override
    void initEvent() {
        all_know_comment_fh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }

    @Override
    void initDate() {

    }
    ListListener<AllCommentKnowBean> allCommentKnowBeanListListener = new ListListener<AllCommentKnowBean>() {
        @Override
        public void onResponse(List<AllCommentKnowBean> list) {
            LinearLayoutManager linearLayoutManager=new LinearLayoutManager(AllKnowCommentActivity.this);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            all_know_comment_rv.setLayoutManager(linearLayoutManager);
            items=list;
            UserFKnowAllCommentAdapter userFKnowAllCommentAdapter=new UserFKnowAllCommentAdapter(AllKnowCommentActivity.this,items,R.layout.allcommentknow_item);
            all_know_comment_rv.setAdapter(userFKnowAllCommentAdapter);
            all_know_comment_rv.setItemAnimator(new DefaultItemAnimator());
            all_know_comment_rv.setEmptyView(all_know_comment_emptyview);
        }

        @Override
        public void onFail(String msg) {

        }
    };

    @Override
    protected void onPause() {
        super.onPause();
        up = true;
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (up) {
            initView();
            initEvent();
            initDate();
            up = false;
        }
    }

}
